package com.jyu.hakkatranslation.Exception;

import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/** 全局异常处理
 * @author Akihi
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    /* spring设置上传文件大小10MB 超出大小捕获异常MaxUploadSizeExceededException */
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public String handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
        log.error("code: " +  500 + ", msg: " + "文件大小超出10MB限制, 请压缩或降低文件质量! ");
        return ("code: " +  500 + ", msg: " + "文件大小超出10MB限制, 请压缩或降低文件质量! ");
    }
}
